<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主界面</title>
    <!--引入elementui得样式-->
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
    <style>
        #foot{
            background-color: #545c64;
        }
        #head {
            background-color: #545c64;
            display: flex;
            justify-content: space-between;
            padding-left: 0;
            align-items: center;
            color: #fff;
            font-size: 20px;
        }

        #h {
            display: flex;
            align-items: center;

        }

        #d {
            margin-left: 15px;

        }

    </style>

    <style>
        .h-footer{
            width: 100%;
            padding: 25px 0 30px;
            text-align: center;
            font-size: 14px;
            color: #6D7278;
            background-color: #545c64;
        }
        .h-footer a{
            font-size: 14px;
            color: #6D7278;
            text-decoration: none;
        }
        .h-footer a:hover{
            color: black;
        }

        .h-footer .footer-cont{
            padding-top: 15px;
        }

    </style>

</head>
<body>
<div id="app">
    <el-container style="height: 100%">

        <el-header id="head"><!-- 头部区 -->
            <div id="h">
                <img src="/imgs/lg.jpg"  height="50px"/>
                <span id="d">益万家综合医院后台管理系统</span>
            </div>




            <div style="margin-left: 580px;">
                <div :data="headAllurl">
                    <el-avatar :src="headAllurl"></el-avatar>
                    <span style="position: absolute;top: 19px;left: 1114px;font-size: 16px;">
                 {{realname}}
                </span>

                </div>

            </div>

            <el-button type="info" @click="logout">退出</el-button>
        </el-header>

        <el-container>
            <el-aside width="200px">
                <el-menu
                        style="overflow: hidden;"
                        default-active="2"
                        class="el-menu-vertical-demo"
                        @open="handleOpen"
                        @close="handleClose"
                        background-color="#545c64"
                        text-color="#fff"
                        active-text-color="#ffd04b">
                    <el-submenu :index="menu.pId" v-for="menu in leftMenu">

                        <template slot="title">
                            <i :class="menu.pIcon"></i>

                            <a style="color: white;text-decoration: none" @click="showContent(menu.pUrl,menu.pName)">
                                {{menu.pName}}
                            </a>
                        </template>

                        <el-menu-item :index="child.pId" v-for="child in menu.children">
                            <i :class="child.pIcon"></i>
                            <a style="color: white;text-decoration: none" @click="showContent(child.pUrl,child.pName)">{{child.pName}}</a>
                        </el-menu-item>
                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-main>
                <!--标签页-->
                <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
                    <el-tab-pane
                            v-for="(item, index) in editableTabs"
                            :key="item.name"
                            :label="item.title"
                            :name="item.name"
                    >
                        <!--   {{item.content}}-->
                        <iframe :src="item.url" frameborder="0" width="100%" height="100%;"></iframe>
                    </el-tab-pane>
                </el-tabs>
            </el-main>
        </el-container>
        <el-footer id="foot" style="background-color:#545c64 ;height: 110px;">

            <div class="h-footer">
                <div class="footer-link">
                    <a href="https://www.haodf.com/info/aboutus.php" rel="nofollow">好大夫在线</a>
                    提供平台支持 Copyright 2022
                    <a href="https://www.haodf.com/info/icp_auth.php" rel="nofollow">京ICP证</a>
                    <a href="https://www.haodf.com/info/ypxxfw_auth.php" rel="nofollow">互联网药品信息服务资格证书(京)-非经营性-2021-0042</a>
                    <a href="https://www.haodf.com/info/hdfyyzz.php" rel="nofollow">营业执照</a>
                    <a href="https://www.haodf.com/info/yljg_auth.php" rel="nofollow">互联网医疗机构许可证</a>
                </div>
                <div class="footer-cont">
                    <a href="https://www.haodf.com/info/contactus.php" rel="nofollow">违法和不良信息举报电话：010-59799065（包含涉未成年人的举报）</a>
                    举报邮箱：service@haodf.com
                </div>
            </div>

        </el-footer>
    </el-container>
</div>
</body>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            headAllurl:'',
            realname:'',
            //左侧菜单
            leftMenu: [],
            //标签页 开始
            editableTabsValue: '1',
            editableTabs: [{
                title: '首页',
                name: '1',
                url: '/home.jsp'
                //content: 'Tab 1 content'
            }],
            tabIndex: 1,
            //显示隐藏图片
            obvious: false,
            picture: '',
        },
        created() {
            this.initLeftMenu();
            this.getuser();
        },
        methods: {
            //退出
            logout() {
                axios.get("/login/quit").then(resp=>{
                    if(resp.data.code===21){
                        location.href = "/homepage.html";
                    }
                })
            },

            //左侧菜单的开闭
            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },

            initLeftMenu() {
                axios.get("/permission/leftPermission").then(resp => {
                    this.leftMenu = resp.data.data;


                })


            },
            //显示当前连接的内容
            showContent(url, menuName) {
                //alert(url+","+menuName);
                //直接调用添加页签页
                this.addTab(menuName, url);
            },
            //添加标签页
            addTab(targetName, url) { //targetName 页签页名称   url 对应的地址
                let newTabName = ++this.tabIndex + '';
                //获取所有的标签页
                let tabs = this.editableTabs;
                //定义是否已经标签变量
                var isHaveTab = false;
                //循环所有页签页 判断当前点击标签页名称已经存在
                tabs.forEach((tab, index) => {
                    //如果为true 说明当前点击节点（部门管理），已经存在标签页
                    if (targetName === tab.title) {// 判断是否相等  1=='1' 值相等  true   1==='1'  false 类型和值都香港等
                        isHaveTab = true;
                        newTabName = tab.name;
                    }
                });
                //如果不存在 添加一个
                if (!isHaveTab) {
                    this.editableTabs.push({
                        title: targetName,
                        name: newTabName,
                        url: url
                        //content: 'New Tab content'
                    });
                }
                //如果存在，直接让高亮
                this.editableTabsValue = newTabName;
            },
            //移除页签页
            removeTab(targetName) {
                let tabs = this.editableTabs;
                let activeName = this.editableTabsValue;
                if (activeName === targetName) {
                    tabs.forEach((tab, index) => {
                        if (tab.name === targetName) {
                            let nextTab = tabs[index + 1] || tabs[index - 1];
                            if (nextTab) {
                                activeName = nextTab.name;
                            }
                        }
                    });
                }

                this.editableTabsValue = activeName;
                this.editableTabs = tabs.filter(tab => tab.name !== targetName);
            },

            //得到当前已经登录的用户的职业（权限）名字
            getuser() {
                axios.post("/login/getuser").then(result => {

                    if (result.data.code === 5025) {
                        if(result.data.data.uId !=null){
                            this.realname = result.data.data.realname;
                            this.headAllurl=result.data.data.headurl;
                        }
                        if(result.data.data.dId !=null){
                            this.realname = result.data.data.dName;
                            this.headAllurl=result.data.data.dHeadurl;
                        }
                        if(result.data.data.aId !=null){
                            this.realname = "超级管理员";
                            this.headAllurl=result.data.data.aHearurl;
                        }

                    }
                })
            },


        }
    })
</script>
<style>
    html, body, #app {
        margin: 0px;
        padding: 0px;
        height: 100%;
    }

    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }

    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }

    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }

    .el-header, .el-footer {
        background-color: #B3C0D1;
        color: #333;
    }

    .el-aside {
        background-color: #545c64;
        color: #333;
        height: 100%;
    }

    .el-main {
        background-color: #E9EEF3;
        color: #333;
        height: 100%;
    }

    body > .el-container {
        height: 100%;
    }

</style>
</html>
